package com.xintoucloud.pbs.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.xintoucloud.pbs.dao.PartyMemberExamObjectDao;
import com.xintoucloud.pbs.entity.PartyMemberExamObject;
@Repository@Transactional
public class PartyMemberExamObjectDaoImpl implements PartyMemberExamObjectDao{
	@Autowired
	private SessionFactory sessionFactory;
	@Override
	public void insertPartyMemberExamObject(PartyMemberExamObject partyMemberExamObject) {
		sessionFactory.getCurrentSession().save(partyMemberExamObject);		
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<PartyMemberExamObject> listPartyMemberExamObject() {
		return sessionFactory.getCurrentSession().createQuery("from PartyMemberExamObject").getResultList();
	}
	@Override
	public long count() {
		return (long) sessionFactory.getCurrentSession().createQuery("select count(*) from PartyMemberExamObject").getSingleResult();
	}
	@Override
	public List<PartyMemberExamObject> listPartyMemberExamObject(int pageIndex, int rows) {
		return sessionFactory.getCurrentSession().createCriteria(PartyMemberExamObject.class).setFirstResult(pageIndex).setMaxResults(rows).list();
	}

}
